<template>
  <header-bar>
    <button is='button' class="button-left">返回</button>
    <p class="title">我是标题</p>
    <button is='button'>历史</button>
  </header-bar>
  <slide-tabs>
    <div class="vita-tab vita-selected">头条</div>
    <div class="vita-tab">娱乐</div>
    <div class="vita-tab">热点</div>
    <div class="vita-tab">广州</div>
    <div class="vita-tab">科技</div>
    <div class="vita-tab">手机</div>
    <div class="vita-tab">数码</div>
    <div class="vita-tab">移动</div>
  </slide-tabs>
  <vita-content :enable-swiper="false">
    <vita-list v-for="list in lists" track-by="$index">
      <vita-item v-for="item in list.dataSource" :item="item" type="vita-item-default" track-by="$index"></vita-item>
    </vita-list>
  </vita-content>
  <vita-tabs>
    <vita-tab title="Title1"></vita-tab>
    <vita-tab title="Title2"></vita-tab>
    <vita-tab title="Title3"></vita-tab>
  </vita-tabs>
</template>

<script>

  import {Button, HeaderBar, SlideTabs, VitaTabs, VitaTab, VitaContent, VitaList, VitaItem} from '../components'
  // import { Store } from '../store'

  let token = 'bbb4beac-cc7f-490b-9e51-adcdaddb8805'

  export default {
    components: {
      HeaderBar, VitaTabs, VitaTab, VitaContent, VitaList, VitaItem, Button, SlideTabs
    },

    props: ['userName'],

    data() {
      return {
        lists: []
      }
    },

    events: {
      'vita-item-tap': (item)=> {
        console.log(item.text)
        alert(item.text)
      }
    },

    methods: {
      fetchItems({category = 3, page = 1, pageSize = 20}) {
        const action = 'action/openapi/news_list'
        // console.log(Vue.http.options)
        return this.$http.get(action, {
          catalog: category,
          page: page,
          pageSize: pageSize
        }).then(function ({data: {newslist, notice}}) {
          //将服务器返回数据，转换成我们需要的数据
          return _.map(newslist, news => {
            return {
              id: news.id,
              label: news.title,
              text: news.title,

            }
          })
        })
      }
    },

    ready() {
      let _this = this
      return
      // this.fetchItems({category: 3, page: 1, pageSize: 20}).then((items)=> {
      //   _this.lists.push({
      //     id: +Date(),
      //     dataSource: items
      //   })
      // })
    }
  }
  
</script>

<style lang='sass'>
  
</style>